package servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;

/**
 * @author JiangJ
 * @date 2022/3/2 14:56
 */
@WebServlet("/AjaxServlet")
public class AjaxServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String email = req.getParameter("email");
//        查询数据库

        //设置响应类型
        resp.setContentType("text/html;charset=UTF-8");

        PrintWriter out = resp.getWriter();
        String res = null;

        int emailcount = 0;
        if (emailcount > 0) {
            res = "{"+"status:200,"+"msg:\"fail\""+"}";
        } else {
            res = "{"+"status:200,"+"msg:\"success\""+"}";
        }
        out.write(res);
        out.flush();
        out.close();
    }
}
